home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 3
/
Cream of the Crop 3.iso
/
comm
/
wnos5src.zip
/
TCPDUMP.C
< prev
next >
Wrap
Text File
|
1993-10-14
|
2KB
|
79 lines
#include "global.h"
#include "mbuf.h"
#include "netuser.h"
#include "internet.h"
#include "tcp.h"
#include "ip.h"
#include "trace.h"
/* Dump a TCP segment header. Assumed to be in network byte order */
void
tcp_dump(
FILE *fp,
struct mbuf **bpp,
int32 source, int32 dest, /* IP source and dest addresses */
int check) /* 0 if checksum test is to be bypassed */
{
struct tcp seg;
struct pseudo_header ph;
int16 csum = 0, dlen;
if(bpp == NULLBUFP || *bpp == NULLBUF) {
return;
}
/* Verify checksum */
ph.source = source;
ph.dest = dest;
ph.protocol = TCP_PTCL;
ph.length = len_p(*bpp);
if(check) {
csum = cksum(&ph,*bpp,ph.length);
}
ntohtcp(&seg,bpp);
trprintf(fp,"TCP: %u->%u Seq x%lx",seg.source,seg.dest,seg.seq,seg.ack);
if(seg.flags.ack) {
trprintf(fp," Ack x%lx",seg.ack);
}
if(seg.flags.congest) {
trprintf(fp," CE");
}
if(seg.flags.urg) {
trprintf(fp," URG");
}
if(seg.flags.ack) {
trprintf(fp," ACK");
}
if(seg.flags.psh) {
trprintf(fp," PSH");
}
if(seg.flags.rst) {
trprintf(fp," RST");
}
if(seg.flags.syn) {
trprintf(fp," SYN");
}
if(seg.flags.fin) {
trprintf(fp," FIN");
}
trprintf(fp," Wnd %u",seg.wnd);
if(seg.flags.urg) {
trprintf(fp," UP x%x",seg.up);
}
/* Print options, if any */
if(seg.mss) {
trprintf(fp," MSS %u",seg.mss);
}
if((dlen = len_p(*bpp)) > 0) {
trprintf(fp," Data %u",dlen);
}
if(csum) {
trprintf(fp," CHECKSUM ERROR (%u)",csum);
}
trprintf(fp,"\n");
}